/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Classes;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Jaroslav
 */
@Entity
@Table(name = "bug_project")
@NamedQueries({@NamedQuery(name = "BugProject.findByBugId", query = "SELECT b FROM BugProject b WHERE b.bugProjectPK.bugId = :bugId"), 
@NamedQuery(name = "BugProject.findByProjectId", query = "SELECT b FROM BugProject b WHERE b.bugProjectPK.projectId = :projectId")})
public class BugProject implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BugProjectPK bugProjectPK;

    public BugProject() {
    }

    public BugProject(BugProjectPK bugProjectPK) {
        this.bugProjectPK = bugProjectPK;
    }

    public BugProject(int bugId, int projectId) {
        this.bugProjectPK = new BugProjectPK(bugId, projectId);
    }

    public BugProjectPK getBugProjectPK() {
        return bugProjectPK;
    }

    public void setBugProjectPK(BugProjectPK bugProjectPK) {
        this.bugProjectPK = bugProjectPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bugProjectPK != null ? bugProjectPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BugProject)) {
            return false;
        }
        BugProject other = (BugProject) object;
        if ((this.bugProjectPK == null && other.bugProjectPK != null) || (this.bugProjectPK != null && !this.bugProjectPK.equals(other.bugProjectPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Classes.BugProject[bugProjectPK=" + bugProjectPK + "]";
    }

}
